***********************
*Time Series Analysis for the Social Sciences
*Box-Steffensmeier, Freeman, Hitt, and Pevehouse
*
*Chapter 4 replication code
************************

*************************
*Figure 4.1
*Use weisLEV85.dta
*Source: http://web.ku.edu/~keds/data.dir/levant.html
*************************

line ip date || line pi date, ///
scheme(s1mono) title(Israeli-Palestinian Interactions: 1985-2005)

line iu date || line ui date, ///
scheme(s1mono) title(Israeli-U.S. Interactions: 1985-2005)

line up date || line pu date, ///
scheme(s1mono) title(U.S.-Palestinian Interactions: 1985-2005)

***************************
*Figure 4.2, Table 4.2, Table 4.3, 
**Use QJPS.dta
*Source: Sattler, Brandt, and Freeman 2010
*************************

tsset time

*Figure 4.2

tsline usxr, title(Pound-Dollar Exchange Rate)
tsline ir, title(Short-term Interest Rate)
tsline pm, title(Prime Ministerial Approval)
tsline cpi, title(Consumer Price Index)

*Table 4.2

	*OLS
	
reg3 (1:cpi ir usxr xrlag1) (2:ir cpi pm pmlag1) if n > 157, ols

	*2SLS
	
reg3 (3:cpi ir usxr xrlag1) (4:ir cpi pm pmlag1) if n> 157, 2sls
	
	*3SLS
	
reg3 (5:cpi ir usxr xrlag1) (6:ir cpi pm pmlag1) if n> 157

*******************
*Table 4.4, Table 4.5, and Figure 4.3
*Use QJPS113.dta
*Source: Sattler, Brandt, and Freeman 2010
*******************

*Table 4.4

varsoc pm cpi ir usxr, maxlag(12)

*Table 4.5

	*First estimate the underlying VAR

var usxr ir cpi pm, lags(1/4) small

	*Granger Causality Tests

vargranger

*Figure 4.3
	*Be sure to first estimate the underlying VAR in Table 4.5 first
	

irf create order2, order(usxr ir cpi pm) set(result) replace

irf graph oirf, irf(order2) impulse(usxr ir cpi pm) response(cpi) level(95) byopts(cols(1)) aspectratio(.2) legend(off) 

irf graph oirf, irf(order2) impulse(usxr ir cpi pm) response(ir) level(95) byopts(cols(1)) aspectratio(.2) legend(off) 

irf graph oirf, irf(order2) impulse(usxr ir cpi pm) response(usxr) level(95) byopts(cols(1)) aspectratio(.2) legend(off) 

irf graph oirf, irf(order2) impulse(usxr ir cpi pm) response(pm) level(95) byopts(cols(1)) aspectratio(.2) legend(off) 
